/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tp1;

import com.mysql.jdbc.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author tulio
 */
public class DbConnection {
    
    private static Connection instance = null;

    private DbConnection(){}

    public static Connection getInstance(){
        if(instance == null) {
            try {
                Class.forName("com.mysql.jdbc.Driver");
                instance = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/TP1?user=root&password=");
            } catch (ClassNotFoundException ex) {
                System.out.println(ex.getMessage());
            } catch (SQLException ex) {
                System.out.println(ex.getMessage());
            }
        }
        return instance;
    }    
}
